﻿namespace ExamV5.LineStudyExam
{
    using ExamV5;
    using System;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public class FrmUPLoadFile : Page
    {
        protected Button butInput;
        protected HtmlForm form1;
        protected HtmlHead Head1;
        private HttpCookie httpCookie_0 = null;
        private HttpCookie httpCookie_1 = null;
        private HttpCookie httpCookie_2 = null;
        private HttpCookie httpCookie_3 = null;
        private int int_0 = 0;
        private int int_1 = 0;
        private int int_2 = 0;
        protected Label labTip;
        private PublicFun publicFun_0 = new PublicFun();
        protected HtmlInputFile UPUserData;

        protected void butInput_Click(object sender, EventArgs e)
        {
            try
            {
                this.labTip.Text = "正在导入中......请稍候......";
                string str = "";
                string fileName = "";
                fileName = this.UPUserData.PostedFile.FileName;
                if (fileName.Trim() != "")
                {
                    string str5 = fileName.Substring(fileName.Length - 4);
                    string str6 = ".asp.exe.dll.bat.aspx.asa.asax.ascx.ashx.asmx.axd.cdx.cer.config.cs.csproj.idc.java.jsl.licx.rem.resources.resx.shtm.shtml.soap.stm.vb.vbproj.vjsproj.vsdisco.webinfo";
                    if (str6.IndexOf(str5.ToLower()) != -1)
                    {
                        this.labTip.Text = "附件文件非法,无法上传！";
                    }
                    else
                    {
                        if (fileName.IndexOf(@"\", 0) > 0)
                        {
                            int num2 = fileName.LastIndexOf(@"\");
                            fileName = fileName.Substring(num2 + 1);
                        }
                        fileName = string.Concat(new object[] { this.httpCookie_0.Value, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Month, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Millisecond, this.int_2.ToString(), str5 });
                        this.UPUserData.PostedFile.SaveAs(base.Server.MapPath("../") + @"\PublicFile\" + fileName);
                        if (!(fileName.Trim() == ""))
                        {
                            str = fileName.Trim();
                        }
                        else
                        {
                            str = "未填写";
                        }
                        string str3 = "";
                        string[] strArray = this.publicFun_0.GetValues(string.Concat(new object[] { "select RubricOWrite from CheckPaper where UserCode='", this.httpCookie_0.Value, "' and PaperID=", this.int_0 }), "RubricOWrite").Split(new char[] { '|' });
                        for (int i = 0; i < (strArray.Length - 1); i++)
                        {
                            if (i != this.int_2)
                            {
                                str3 = str3 + strArray[i].ToString() + "|";
                            }
                            else
                            {
                                str3 = str3 + str + "|";
                            }
                        }
                        this.publicFun_0.ExecuteSql(string.Concat(new object[] { "update CheckPaper set RubricOWrite='", str3, "' where UserCode='", this.httpCookie_0.Value, "' and PaperID=", this.int_0 }));
                        this.labTip.Text = "导入操作成功！";
                    }
                }
            }
            catch
            {
                this.labTip.Text = "导入操作失败,请重新操作！";
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            this.httpCookie_0 = new HttpCookie("ExamUserCode");
            this.httpCookie_0 = base.Request.Cookies["ExamUserCode"];
            this.httpCookie_1 = new HttpCookie("ExamUserName");
            this.httpCookie_1 = base.Request.Cookies["ExamUserName"];
            this.httpCookie_2 = new HttpCookie("ExamUserLevel");
            this.httpCookie_2 = base.Request.Cookies["ExamUserLevel"];
            this.httpCookie_3 = new HttpCookie("ExamDeptID");
            this.httpCookie_3 = base.Request.Cookies["ExamDeptID"];
            if ((this.httpCookie_0 != null) ? !(this.httpCookie_0.Value == "") : false)
            {
                base.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                base.Response.Cache.SetNoStore();
                this.httpCookie_0.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_0.Value));
                this.httpCookie_1.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_1.Value));
                this.httpCookie_2.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_2.Value));
                this.httpCookie_3.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_3.Value));
                this.int_0 = Convert.ToInt32(base.Request["PaperID"].ToString());
                this.int_1 = Convert.ToInt32(base.Request["ID"].ToString());
                this.int_2 = Convert.ToInt32(base.Request["Sort"].ToString());
            }
            else
            {
                base.Response.Write("<script language=javascript>top.location.href='../Index.htm';self.close();</script>");
            }
        }
    }
}

